package cn.lizemin.controller;

import cn.lizemin.exception.UserNameNotFoundException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author lzm
 * @version 1.0
 * @description: TODO
 * @date 2022/1/9 12:33
 */
@Controller
@RequestMapping("/")
public class DemoController {

    @RequestMapping("demo")
    public String demo() {
        System.out.println("demo ok....");
        int n = 1 / 0;
//        try {
//            int n = 1 / 0;
//        } catch (Exception e) {
//            return "500";
//            e.printStackTrace();
//        }
        return "hello";
    }

    @RequestMapping("login")
    public String login(String username,String password){
        System.out.println("login ...");
        System.out.println("username: "+username);
        System.out.println("password: "+password);
        if("xiaochen".equals(username) && "123".equals(password)){
            return "hello";//返回成功页面
        }else{
            throw new UserNameNotFoundException("用户名不正确!!");
        }
    }

}
